
//字母大小写全排列
class Solution {
public:
    vector<string> res;
    string tmp;
    vector<string> letterCasePermutation(string s) 
    {
        dfs(s,0);
        return res;
    }
    char change(char ch)
    {
        if(ch >= 'a' && ch <= 'z') ch -= 32;
        else ch += 32;
        return ch;
    }
    void dfs(string s,int index)
    {
        if(tmp.size()==s.size())
        {
            res.push_back(tmp);
            return;
        }
        char ch=s[index];
        tmp.push_back(ch);
        dfs(s,index+1);
        tmp.pop_back();
        if(ch>'9' || ch<'0')
        {
            ch=change(ch);
            tmp.push_back(ch);
            dfs(s,index+1);
            tmp.pop_back();
        }
    };
};

//找出所有子集的异或总和再求和

class Solution {
public:
    // vector<vector<int>>res;
    // vector<int>tmp;
    int sum=0;
    int path=0;
    int subsetXORSum(vector<int>& nums) 
    {
       dfs(nums,0);
       return sum;
    }
    void dfs(vector<int>& nums,int index)
    {
        // res.push_back(tmp);
        sum+=path;//每次走到这里都是一个子集 path里面是当前子集的异或结果
        for(int i=index;i<nums.size();i++)
        {
            // tmp.push_back(nums[i]);
            path^=nums[i];
            dfs(nums,i+1);
            // tmp.pop_back();
            path^=nums[i];
        }
    }
};